package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;

import com.ruoyi.web.controller.system.domain.OpenId;
import com.ruoyi.web.controller.system.service.IOpenIdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2020-12-20
 */
@RestController
@RequestMapping("/system/id")
public class OpenIdController extends BaseController
{
    @Autowired
    private IOpenIdService openIdService;

    /**
     * 查询【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:id:list')")
    @GetMapping("/list")
    public TableDataInfo list(OpenId openId)
    {
        startPage();
        List<OpenId> list = openIdService.selectOpenIdList(openId);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:id:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OpenId openId)
    {
        List<OpenId> list = openIdService.selectOpenIdList(openId);
        ExcelUtil<OpenId> util = new ExcelUtil<OpenId>(OpenId.class);
        return util.exportExcel(list, "id");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:id:query')")
    @GetMapping(value = "/{index}")
    public AjaxResult getInfo(@PathVariable("index") Long index)
    {
        return AjaxResult.success(openIdService.selectOpenIdById(index));
    }

    /**
     * 新增【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:id:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OpenId openId)
    {
        return toAjax(openIdService.insertOpenId(openId));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:id:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OpenId openId)
    {
        return toAjax(openIdService.updateOpenId(openId));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:id:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{indexs}")
    public AjaxResult remove(@PathVariable Long[] indexs)
    {
        return toAjax(openIdService.deleteOpenIdByIds(indexs));
    }
}
